<?php
declare (strict_types = 1);

namespace app\middleware;


class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     */
    public function handle($request, \Closure $next)
    {
        // 记住当前地址并重定向
        if (session('admin_id') < 1 || empty(session('admin_id'))) {
            $url=url('Admin/login');
//            return redirect('Main/login');
            $js = "<script>window.top.location.href='$url'</script>";
            echo $js;
        }
        return $next($request);
    }
}
